package 传智播客_黑马.java基础.LearnException;

import java.util.Objects;

/*
    Objects 类中的静态方法
        源码:
        public static <T> T requireNonNull(T obj){
            if(obj == null){
                throw new NullPointerException();
            return obj;
            }
        }
 */
public class Object非空判断 {
    public static void method(Object obj){
        //对传递的参数进行合法性判断
//        if(obj == null){
//            throw new NullPointerException("传递的对象的值是null");
//        }
        Objects.requireNonNull(obj);
        Objects.requireNonNull(obj,"传递的对象的值是null");

    }
}
